package com.ziki.bswicket.component;

import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.IDataProvider;

import com.ziki.bswicket.action.PopulateAction;
import com.ziki.framework.wicket.markup.repeater.FwDataView;

public class BsDataView<T> extends FwDataView<T> {
    private static final long serialVersionUID = 1L;
    private PopulateAction<T> action;

    public BsDataView(String id, IDataProvider<T> dataProvider) {
        super(id, dataProvider);
    }

    public BsDataView(String id, IDataProvider<T> dataProvider, long itemsPerPage) {
        super(id, dataProvider, itemsPerPage);
    }

    public void add(PopulateAction<T> action) {
        this.action = action;
    }

    @Override
    protected void populateItem(Item<T> item) {
        if (this.action != null) {
            this.action.performPopulate(item);
        }
    }

}
